package com.abel.roommanager.provider;

import java.util.Map;

import org.apache.ibatis.jdbc.SQL;

import com.abel.roommanager.pojo.Room;

public class RoomsCountSql {
     public String getSql(Map<String, Object> map) {
    	 Room room=(Room) map.get("room");
    	 int enableLiving=(int) map.get("enableLiving");
    	  SQL sql=new SQL().SELECT("count(*)").FROM("room");
    	   if (room.getAddress()!=null&&room.getAddress().length()!=0) {
    			sql.WHERE("address like '"+room.getAddress()+"'");
    		}
    		   if (enableLiving==1) {
    			sql.WHERE("capacity>livenumber");
    		}
    		   if (room.getState()!=0) {
    			sql.WHERE("state="+room.getState());
    		}
    		   if (room.getType()!=0) {
    			sql.WHERE("type="+room.getType());
    		}
		return sql.toString();
		
	}
}
